package com.ydd.controller.admin;

import com.ydd.dto.LoginDTO;
import com.ydd.result.Result;
import com.ydd.service.ISysUserService;
import com.ydd.service.IndexService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/index")
@Api(tags = "基础模块")
@Slf4j
public class IndexController {
    @Autowired
    private IndexService indexService;

    @Autowired
    private ISysUserService iSysUserService;

    @ApiOperation("获取系统配置")
    @GetMapping("/getConfig")
    public Result getConfig() {
        log.info("获取系统配置");
        return indexService.getConfig();
    }

    @ApiOperation("登录接口")
    @PostMapping("/login")
    public Result login(@RequestBody LoginDTO dto) {
        log.info("登录");
        return indexService.login(dto);
//        return null;
    }

    @ApiOperation("获取用户资料")
    @PostMapping("/profile")
    public Result profile() {
        log.info("获取用户资料");
        return indexService.profile();

    }

    @ApiOperation("主页信息统计")
    @GetMapping("/baseInfo")
    public Result baseInfo() {
        log.info("主页信息统计");
        return iSysUserService.baseInfo();

    }

}
